package com.caszx.chargingpile.fragment;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.app.base.fragment.BaseDelayNetFragment;
import com.app.utils.SystemHelper;
import com.caszx.chargingpile.R;
import com.caszx.chargingpile.eventbus.EventBusAction;

import de.greenrobot.event.EventBus;

/**
 * Created by think on 2016/6/30.
 */
public class TabHomeFragment extends BaseDelayNetFragment {


    public static TabHomeFragment newInstance() {
        TabHomeFragment fragment = new TabHomeFragment();
        return fragment;
    }


    @Override
    protected View initOnloadedView() {
        View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_tab_home,null);
        initView(view);
        ImageView image_banner = (ImageView) view.findViewById(R.id.image_banner);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) image_banner.getLayoutParams();
        layoutParams.width = SystemHelper.getScreenWidth(getContext());
        layoutParams.height = layoutParams.width;
        image_banner.setLayoutParams(layoutParams);
        return view;
    }

    private void initView(View view){
        view.findViewById(R.id.layout_01).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(EventBusAction.ACTION_HOME_STATION);
            }
        });

        view.findViewById(R.id.layout_02).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                EventBus.getDefault().post(EventBusAction.ACTION_HOME_RESERVATE);
            }
        });
        view.findViewById(R.id.layout_03).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(EventBusAction.ACTION_HOME_QRCODE);
            }
        });
        view.findViewById(R.id.layout_04).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(EventBusAction.ACTION_HOME_USER);
            }
        });


    }

}
